#ifndef __TEMPERATURE_H__
#define __TEMPERATURE_H__
#define I2C_USED            I2C2
#define I2C_CLK             RCC_APB1Periph_I2C2
#define I2C_CLOCK_HZ        100000

#define I2C_GPIO_PORT       GPIOB
#define I2C_GPIO_CLK        RCC_APB2Periph_GPIOB
#define I2C_SCL_PIN         GPIO_Pin_10
#define I2C_SDA_PIN         GPIO_Pin_11

#define ADC_GPIO_PORT       GPIOB
#define ADC_PIN             GPIO_Pin_10


#define TEMPERATURE_ADDR    0x48
#define TEMP_REG            0x00
#define CONFIG_REG          0x01
#define HYST_REG            0x02
#define SET_REG             0x03

#define DATA_SIZE           2

#define TEMPERATURE_RETRY   100

#define LM35

enum X_I2C_MODE {
    READ = 1,
    WRITE = 0
};

struct xtemperature {
    unsigned char temparature_round;
    unsigned char temparature_half;
    error_callback_t temp_error_handler;
};

#ifdef __cplusplus
extern "C" {
#endif

extern void temperature_open(struct xtemperature *temperature);
extern unsigned char temperature_get(struct xtemperature *temperature);
extern unsigned char temperature_set(struct xtemperature *temperature);
extern void temperature_close(void);

#ifdef __cplusplus
}
#endif

#endif